package com.tyoj.model.vo;

import com.tyoj.model.entity.QuestionThumb;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * 帖子视图
 */
@Data
public class QuestionSubmmitVO implements Serializable {

    /**
     * id
     */
    private Long id;

    /**
     * 用户代码
     */
    private String code;

    /**
     * 编程语言
     */
    private String language;

    /**
     * 题目 id
     */
    private Long questionId;

    /**
     * 判题状态
     */
    private Integer status;

    /**
     * 判题结果(json 对象)
     */
    private String judgeInfo;

    /**
     * 创建用户 id
     */
    private Long userId;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;


    /**
     * 包装类转对象
     */
    public static QuestionThumb voToObj(QuestionSubmmitVO questionSubmmitVO) {
        if (questionSubmmitVO == null) {
            return null;
        }
        QuestionThumb questionThumb = new QuestionThumb();
        BeanUtils.copyProperties(questionSubmmitVO, questionThumb);
        return questionThumb;
    }

    /**
     * 对象转包装类
     *
     * @return
     */
    public static QuestionSubmmitVO objToVo(QuestionThumb questionThumb) {
        if (questionThumb == null) {
            return null;
        }
        QuestionSubmmitVO questionSubmmitVO = new QuestionSubmmitVO();
        BeanUtils.copyProperties(questionThumb, questionSubmmitVO);
        return questionSubmmitVO;
    }

    private static final long serialVersionUID = 1L;
}
